import QtQuick 2.12
import QtQuick.Controls 2.5

import QtQuick.Layouts 1.12
Button{

    //icon的地址
    property string iconSource
    //icon宽高
    property int iconWidth
    property int iconHeight
    //icon的Name
    property string iconName
    //文字
    property string buttonTitle
    //移入时颜色
    property string moveIconColor
    //移入时背景颜色
    property string moveRectangleColor
    //默认图标颜色
    property string defaultIconColor
    //默认背景颜色
    property string defaultRectangleColor
    //移出时Icon颜色
    property string removeIconCorlor
    //移出时背景颜色
    property string removeRectangleColor
    //圆角
    property int defaultradius
    //跳转
    property string loadrerPageUrl
    //点击颜色


   property int buttonWidth
   property int buttonHeight
   property string isC



    id:button
    width:buttonWidth?buttonWidth:30
    height:buttonWidth?buttonWidth:30
    icon{
        source: iconSource
        width: iconWidth?iconWidth:50
        height: iconHeight?iconWidth:50
        color: defaultIconColor
    }
    Text {
        id: name
        anchors.bottom: button.bottom
        text: qsTr(buttonTitle)
    }
    onClicked: {
        console.log("11")}

    background: Rectangle{

        id:btnRectangle
        radius:defaultradius?defaultradius:0
        anchors.fill: parent
        color:defaultRectangleColor
        MouseArea{
            anchors.fill: parent;
            hoverEnabled: true;
            onEntered: {    //鼠标移入
                button.icon.color = moveIconColor
                //背景色
                btnRectangle.color =moveRectangleColor;
            }
            onExited: {
                //移出icon颜色
                button.icon.color = removeIconCorlor;
                //移出背景色
                btnRectangle.color = removeRectangleColor;

            }
            onPressed: {
x
                //移出背景色
                btnRectangle.color = "black";
            }
            onClicked: {
                if(iconName=="cha")appWindoow.close()
                if(loadrerPageUrl){

                    if(loadrerPageUrl=="ChatPage.qml"){

                      appWindoow.loding(loadrerPageUrl)

                    }
                    loginPageItem.loding(loadrerPageUrl)
                }

            }



        }

    }

    function request() {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
                print('HEADERS_RECEIVED')
                    console.log(xhr.responseText.toString())
            } else if(xhr.readyState === XMLHttpRequest.DONE) {
                print('DONE')
                var json = JSON.parse(xhr.responseText.toString())

                console.log(xhr)
            }
        }
        xhr.open("GET", "http://localhost:8080/user/hello");
        xhr.send();
    }
}







